<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use think\Db;
use think\Session;
use \think\Request;

class User extends AdminBase
{
    public function index()
    {
        $map = input("param.");

        $where["a.status"] = ["gt",0];
        $Arr = [];
        if(!empty($map["realname"])){
            $where["a.realname"] = $map["realname"];
            $Arr["realname"] = $map["realname"];
        }
        if(!empty($map["account"])){
            $where["a.account"] = $map["account"];
            $Arr["account"] = $map["account"];
        }
        if( isset($map["level"]) && $map["level"] != "" ){
            $where["a.level"] = $map["level"];
            $Arr["level"] = $map["level"];
        }
        $list = app_model("Admin","User")->get_pageList($where);
        $this->assign("pagetotal",$this->getPageTotal($list));
		$this->assign('list',$list);
        $this->assign('Arr',$Arr);
		return $this->fetch();
    }


    //会员详情
    public function details(){

        $id = input('param.id');
        if( empty($id) ){
            $this->error("错误数据");
        }
        $Arr = app_model("Index","User")->getuserInfo($id);
        $this->assign('Arr',$Arr);
        return $this->fetch();
    }

    //代理商
    public function agent(){
        $map = input("param.");

        $where["a.status"] = ["gt",0];
        $where["a.agent_id"] = ["gt",0];
        $where["e.type"] = ["eq",2];
        $Arr = [];
        if(!empty($map["realname"])){
            $where["a.realname"] = $map["realname"];
            $Arr["realname"] = $map["realname"];
        }
        if(!empty($map["phone"])){
            $where["a.phone"] = $map["phone"];
            $Arr["phone"] = $map["phone"];
        }
        if( isset($map["agent"]) && $map["agent"] != "" ){
            $where["a.agent"] = $map["agent"];
            $Arr["agent"] = $map["agent"];
        }
        $list = app_model("Admin","User")->get_agentList($where);
        $this->assign("pagetotal",$this->getPageTotal($list));
        $this->assign('list',$list);
        $this->assign('Arr',$Arr);
        return $this->fetch();
    }
}